<?php namespace web\admin\controller;
	
	class Orderlist extends Common{
		private $db;
		public function __construct(){
			parent::__construct();
			$this->db=new \system\model\orderlist;
		}
		
	//首页
	public function index() {
		View::with('title','订单列表');
		
//		获取数据返回页面
		$data=Db::table('orders')->get();
		View::with('data',$data);
		View::make();
	}


//		删除商品
		public function del(){
			$attrModel=new \system\model\goods_attr;
			$detail=new \system\model\detail;
			$gid=Q('get.gid',0,'intval');
//			删除商品属性
			$attrModel->where('gid',$gid)->delete();
//			删除商品详情
			$detail->where('gid',$gid)->delete();
//			删除商品列表
			$this->db->where('gid',$gid)->delete();
			message('删除成功','index');
		}
		
//		编辑商品
		public function edit(){
//			获取get参数
//			p($gid);die;		
			if(IS_POST){
//				p($_POST);die;
				$re=$this->db->store();
				if(!$re){
					message($this->db->getError(),'','error');
				}
				message('1','','success');

			}

		    
		}
//		获取数据
		public function listData(){
			$oid=Q('post.oid',0,'intval');
			$data=Db::table('orders')->where('oid',$oid)->first();
			message($data,'','success');
			
		}
		
//		订单详情列表
		public function orderlist(){
			$oid=Q('get.oid',0,'intval');
			$data=$this->db->join('goods_list','orderlist.glid','=','goods_list.glid')
			->join('goods','orderlist.gid','=','goods.gid')
			->join('orders','orderlist.oid','=','orders.oid')
			->where('orders.oid',$oid)->get();
			foreach ($data as $key => $value) {
				$data[$key]['combine']=explode('|',$value['combine']);
				foreach($data[$key]['combine'] as $k=>$v){
					$data[$key]['combine'][$k]=Db::table('goods_attr')->where('gtid',$v)->pluck('gtvalue');
				}
				$data[$key]['combine']=implode('|',$data[$key]['combine']);
			}
//			p($data);die;
			View::with('data',$data);
			View::make();
		}
		
		
		
	}
	
	
	
	
?>